package com.itheima.work;


import java.util.LinkedHashSet;
import java.util.Scanner;

/**
 * @auther Macrydy
 * @date 2020/6/30 19:20
 *
 * 键盘录入一个字符串，去掉其中重复字符，打印出不同的那些字符，必须保证顺序。例如输入：aaaabbbcccddd，打印结果为：abcd。
 */
public class Test6 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入：");
        String s = scanner.nextLine();
        char[] chars = s.toCharArray();

        LinkedHashSet<Character> set = new LinkedHashSet<>();

        for (char aChar : chars) {
            set.add(aChar);
        }

        StringBuilder sb = new StringBuilder();
        for (Character character : set) {
            sb.append(character);
        }
        System.out.println(sb.toString());
    }
}
